<?php

define('ACC', true);
require('./include/init.php');
session_start(); 
//print_r($_SESSION);
$userid = $_SESSION['user_id'];

echo '<head><meta charset = "utf-8"></head>';  
//$userid = 26;

$company = new companymodel();
$companyinfo = $company->getcompanyinfo($userid);
$companyid = $companyinfo['company_id'];

$cashinfo = $company->getcash_equivalent($companyid);
$totalcashequivalent = 0;
$order = $company->getorder($companyid);
$totalordervolume = 0;

foreach($order as $k=>$v){
    $totalordervolume = $totalordervolume + $v['order_number'];
}

 
foreach($cashinfo as $k=>$v){
    $totalcashequivalent = $totalcashequivalent + $v;
}
 
$loaninfo = $company->getloan($companyid);
$totalloan = 0;
foreach($loaninfo as $k=>$v){
    $totalloan = $totalloan + $v['current_value'];
}



$rawmaterialinstockinfo = $company->getrawmaterialinstock($companyid);
$numofrawmaterialinstock = 0;
foreach($rawmaterialinstockinfo as $k=>$v){
    $numofrawmaterialinstock = $numofrawmaterialinstock + $v;
}


$rawmaterialonthewayinfo = $company->getrawmaterialontheway($companyid);

$finishedgoodinfo = $company->getfinishedgood($companyid);
$numoffinishedgood = 0;
foreach($finishedgoodinfo as $k=>$v){
    $numoffinishedgood = $numoffinishedgood + $v;
}

$buildinginfo = $company->getallelements($companyid, 'building');

$actionlog = $company->getactionlog($companyid, 20);
 
 

include(ROOT . 'view/dashboard.html');

?>
